<template>
  <div class="data-card-list" :style="listStyle">
    <div
        class="data-card"
        v-for="(item, index) in dataList"
        :key="index"
        :style="cardStyle"
    >
    <!-- 图标在左 -->
    <div class="data-icon">
      <img :src="item.icon" alt="" />
    </div>

    <!-- 数据在右 -->
    <div class="data-content">
      <div class="data-title">{{ item.label }}</div>
      <div class="data-value">
        {{ item.value }}
        <span class="data-unit">{{ item.unit }}</span>
      </div>
    </div>
  </div>
  </div>
</template>

<script>
export default {
  name: 'DataCardList',
  props: {
    dataList: {
      type: Array,
      required: true,
      description: '数据卡片列表数据'
    },
    // 卡片间距（默认16px）
    gap: {
      type: String,
      default: '16px'
    },
    // 统一卡片宽度
    cardWidth: {
      type: String,
      default: '180px'
    },
    // 统一卡片高度
    cardHeight: {
      type: String,
      default: '70px'
    }
  },
  data() {
    return {

    }
  },
  computed: {
    // 列表容器样式（动态间距）
    listStyle() {
      return {
        gap: this.gap,
      };
    },
    // 卡片样式（动态宽高）
    cardStyle() {
      return {
        width: this.cardWidth,
        height: this.cardHeight
      };
    }
  }
};
</script>

<style lang="scss" scoped>
.data-card-list {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
}

.data-card {
  display: flex;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  gap: 16px;
  transition: all 0.2s ease;
  background-color: rgba(61, 231, 201, 0.15);
  box-sizing: border-box; /* 确保padding不影响宽高 */

  &:hover {
    background-color: rgba(61, 231, 201, 0.4);
  }

  .data-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;

    img {
      width: 100%;
      height: 100%;
      object-fit: contain;
    }
  }

  .data-content {
    flex: 1;

    .data-title {
      font-size: 14px;
      margin-bottom: 5px;
    }

    .data-value {
      font-size: 16px;
      font-weight: 600;

      .data-unit {
        font-size: 13px;
        font-weight: normal;
        margin-left: 4px;
      }
    }
  }
}
</style>
